{{- $content := .Inner | safeHTML -}}
{{- $tabs := .Scratch.Get "tabs" -}}
{{- $ordinal := .Ordinal -}}
{{- $name := printf "tabs-%s" $ordinal -}}
{{- $active := false -}}

<div class='mkdocs tabs' name="{{ $name }}">
{{- range $index, $tab := $tabs -}}
    {{- $id := printf "tabs-%s-%s" $ordinal $index -}}
    {{- $checked := false -}}
    {{- if and (not $active) ($tab.content) -}}
        {{- $checked = true -}}
        {{- $active = true -}}
    {{- end -}}
    <input type='radio' class='toggle' name="{{ $name }}" id="{{ $id }}" {{ if $checked }}checked="checked"{{ end }}>
    <label class="label {{ if not $tab.content }}disabled{{ end }}" for="{{ $id }}">{{ $tab.title }}</label>
    <div class='inner'>{{ $tab.content }}</div>
{{- end -}}
</div>